package team.knowers.agency.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import team.knowers.agency.common.convention.result.Result;
import team.knowers.agency.common.convention.result.Results;
import team.knowers.agency.dao.entity.PaymentDO;
import team.knowers.agency.dto.req.MorePaymentCreateReqDTO;
import team.knowers.agency.dto.req.PaymentCreateReqDTO;
import team.knowers.agency.service.PaymentService;

import java.util.List;


@RestController
@RequiredArgsConstructor
public class PaymentController {
    private final PaymentService paymentService;
    /**
     * 创建订单
     * @param req
     */
    @PutMapping("/api/agency/payment/createPayment")
    public Result<Void> createPayment (@RequestBody PaymentCreateReqDTO req)
    {
        paymentService.createPayment(req);
        return Results.success();
    }
    /**
     * 取消订单
     * @param id
     */
    @PostMapping("/api/agency/payment/cancelPayment")
    public Result<Void> cancelPayment(@RequestParam int id)
    {
        paymentService.cancelPayment(id);
        return Results.success();
    }
    /**
     * 支付订单
     */
    @PostMapping("/api/agency/payment/payPayment")
    public Result<Void> payPayment(@RequestParam int id){
        paymentService.payPayment(id);
        return Results.success();
    }
    @GetMapping("/api/agency/payment/viewOrder/{touristId}")
    public Result<List<PaymentDO>> viewOrder(@PathVariable int touristId)
    {
        return Results.success(paymentService.viewOrder(touristId));
    }
    @PostMapping("/api/agency/payment/moreCreatePayment")
    public Result<Void>  moreCreatePayment(MorePaymentCreateReqDTO req)
    {
        paymentService.moreCreatePayment(req);
        return Results.success();
    }

}
